export function setToken(token) {
    return localStorage.setItem('token', token)
}
export function getToken() {
    return localStorage.getItem('token') || ''
}

/**
 * 将list转为true
*/
export function listToTree(list) {
    const map = {}
    const result = []
    list.forEach(element => {
        map[element.id] = {...element}
    });
    list.forEach(item => {
        if (item.parentId) {
            if(map[item.parentId].children) {
                map[item.parentId].children.push(map[item.id])
            }else {
                map[item.parentId].children = [map[item.id]]
            }
        }else {
            result.push(map[item.id])
        }
    });
    return result 
}